/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.bff.slimserver.musicjukebox.ui.components;

import com.bff.bjj.ui.component.ColorProperties;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Graphics;
import javax.swing.BorderFactory;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextArea;

/**
 *
 * @author Music
 */
public class RoundedTextArea extends JTextArea {

    public RoundedTextArea() {
        // We must be non-opaque since we won't fill all pixels.
        // This will also stop the UI from filling our background.
        setOpaque(false);

        // Add an empty border around us to compensate for
        // the rounded corners.
        setBorder(BorderFactory.createEmptyBorder(3, 5, 3, 5));
    }

    protected void paintComponent(Graphics g) {
        int width = getWidth();
        int height = getHeight();

        // Paint a rounded rectangle in the background.
        g.setColor(getBackground());
        g.fillRoundRect(0, 0, width, height, height, height);

        // Now call the superclass behavior to paint the foreground.
        super.paintComponent(g);
    }

    /*
    protected void paintComponent(Graphics g) {
        int w = getWidth();
        int h = getHeight();
        RenderingHints renderHints = new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
        renderHints.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
        renderHints.put(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_OFF);

        Graphics2D g2d = (Graphics2D) g;
        AlphaComposite alphaComposite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha);
        g2d.setComposite(alphaComposite);
        g2d.setRenderingHints(renderHints);
        g2d.setColor(getBackground());
        g2d.fillRoundRect(0, 0, w, h, h, h);

        if (borderColor != null) {
            g2d.setColor(borderColor);
            g2d.drawRoundRect(0, 0, w - 1, h - 1, h - 1, h - 1);
        }

        super.paintComponent(g);
    }
     */
    
    public static void main(String[] args) {
        JFrame f = new JFrame();
        f.setLayout(new BorderLayout());
        
        JPanel p = new JPanel(new FlowLayout());
        
        RoundedTextArea ta = new RoundedTextArea();
        ta.setPreferredSize(new Dimension(300, 50));
        ta.setBackground(ColorProperties.PLAYER_INSERT);
        
        p.add(ta);
        
        f.add(p, BorderLayout.CENTER);
        
        f.setVisible(true);
        
        
    }
}
